package com.glfx;

import nl.siegmann.epublib.domain.Author;
import nl.siegmann.epublib.domain.Book;
import nl.siegmann.epublib.domain.Date;
import nl.siegmann.epublib.domain.Resource;
import nl.siegmann.epublib.epub.EpubWriter;

import java.io.*;
import java.util.ArrayList;
import java.util.List;

public class Main
{
	public static final String DISK_DIR_ROOT = "C:/book1/";


	public static void main(String[] args)
	{
		try
		{
			Book book = new Book();
 
			book.getMetadata().addTitle("三国演义");
			book.getMetadata().addAuthor(new Author("罗贯中", "吴承恩"));
			book.getMetadata().addContributor(new Author("zhang"));
			book.getMetadata().addPublisher("zhang");
			//List<String> list= new list;
			List<String> list=new ArrayList<String>();
			list.add("publish-哈哈");list.add("publish-嘿嘿");
			book.getMetadata().setPublishers(list);
			list=new ArrayList<String>();
			list.add("Descriptions-哈哈");list.add("Descriptions-嘿嘿");
			book.getMetadata().setDescriptions(list);
			List<Date> list2 = new ArrayList<Date>();
			list2.add(new Date(new java.util.Date()));
			book.getMetadata().setDates(list2);
			book.getMetadata().setSubjects(list);
 
			book.addSection("introduce", new Resource(new FileInputStream(
					new File(DISK_DIR_ROOT + "haha.html")), "haha.html"));
//			book.setCoverImage(new Resource(new FileInputStream(new File(
//					DISK_DIR_ROOT + "cover.png")), "cover.png"));
 
			EpubWriter epubWriter = new EpubWriter();
			epubWriter.write(book, new FileOutputStream(new File("test.epub")));
			System.out.println("ok");
 
		} catch (FileNotFoundException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
 
	}
}